<!-- msgBox.vue组件 -->
<template>
<div id="msg_bg" v-show="show" @click="bg_close">
  <div class="msgBox-box" >
        <div class="msgBox-mask"></div>
        <div class="msgBox-content">
            <div class="title">{{title}}</div>
            <div class="text">{{text}}</div>
            <div class="btn_box" v-show="showCancelBtn || showConfirmBtn" >
              <div class="btn_left" @click="btn_cancel" v-show="showCancelBtn">取消</div>
              <div class="btn_right" @click="btn_confirm" v-show="showConfirmBtn">确认</div>
            </div>
        </div>
    </div>
</div>


</template>

<script>
export default {
  props: {
    show: Boolean,
    text: {
      type: String,
      default: "请确认信息。"
    },
    title: {
      type: String,
      default: "提示信息"
    },
    showCancelBtn:Boolean,
    showConfirmBtn:Boolean,
    CancelFunction:Function,
    ConfirmFunction:Function,
  },
  methods:{
    bg_close(){
      this.show = false;
    },
    btn_cancel(){
      this.show = false;
      if(this.CancelFunction){
        this.CancelFunction()
      }
    },
    btn_confirm(){
      this.show = false;
      if(this.ConfirmFunction){
        this.ConfirmFunction()
      }
    },
  }
};
</script>
<style scoped>
#msg_bg{
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 2003;
}
.msgBox-box {
  padding: 0.1rem 0.2rem 0 0.2rem;
  box-sizing: border-box;
  min-width: 100px;
  border-radius: 5%;
  text-align: center;
  background-color:#fff;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.title{
  border-bottom: 1px solid #ddd;
  padding: 0.1rem 0;
}
.text{
    font-size: 0.28rem;
  color: #333;
  padding: 0.2rem 0;
}
.btn_box{
  display: flex;
  justify-content: space-between;
}
.btn_box{
  border-top: 1px solid #ddd;
}
.btn_box div{
width: 50%;
padding: 0.13rem;
}
.btn_left{
  border-right: 1px solid #ddd;
}
</style>
